//
//  YQNewFeatureCell.m
//  WeiboOC
//
//  Created by yang on 15/11/16.
//  Copyright © 2015年 yang. All rights reserved.
//

#import "YQNewFeatureCell.h"
@interface YQNewFeatureCell ()
@property (nonatomic, strong) UIImageView* iconImage;
@end
@implementation YQNewFeatureCell
- (UIImageView*)iconImage
{
    if (!_iconImage) {
        UIImageView* iconImage = [[UIImageView alloc] init];
        _iconImage = iconImage;
    }
    return _iconImage;
}
- (UIButton*)startButton
{
    if (!_startButton) {
        UIButton* startButton = [[UIButton alloc] initWithTitle:@"开始体验" backImage:@"new_feature_finish_button" color:nil image:nil size:0];
        _startButton = startButton;
    }
    return _startButton;
}
- (void)setIndex:(NSInteger)index
{
    _index = index;
    self.iconImage.image = [UIImage imageNamed:[NSString stringWithFormat:@"new_feature_%zd", index + 1]];
    self.startButton.hidden = YES;
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor randomColor];
        [self setupUI];
    }
    return self;
}
- (void)setupUI
{
    [self.contentView addSubview:self.iconImage];
    [self.contentView addSubview:self.startButton];
    [self.iconImage makeConstraints:^(MASConstraintMaker* make) {
        make.edges.equalTo(self.contentView);
    }];
    [self.startButton makeConstraints:^(MASConstraintMaker* make) {
        make.centerX.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView).offset(-200);
    }];
}
- (void)startAnimation
{
    self.startButton.transform = CGAffineTransformMakeScale(0, 0);
    self.startButton.hidden = false;
    [UIView animateWithDuration:1
        delay:0
        usingSpringWithDamping:0.5
        initialSpringVelocity:5
        options:UIViewAnimationOptionTransitionNone
        animations:^{
            self.startButton.transform = CGAffineTransformMakeScale(1, 1);
        }
        completion:^(BOOL finished){

        }];
}
@end
